#ifndef COLUMNSENTRY_H
#define COLUMNSENTRY_H

#include <QObject>

/**
 * @brief The Columns class
 *
 * /media/zinface/WD_DATA/lineage-rpi
 *  项目名称: lineage-rpi/android_kernel_brcm_rpi
 *  检出位置: common
 *  远程仓库: github
 *  修订版本: lineage-20.0
 *
 *
 * Columns
 *  row: 0
 *  name: lineage-rpi/android_kernel_brcm_rpi
 *  path: common
 *  realpath: /media/zinface/WD_DATA/lineage-rpi/common
 *  checkeouted;        // true: 已检出，false: 未检出
 *  checkeouted_text;
 *  solution;           // true: 正常, false: 空目录(除 .git 外无文件)/可瘦身/
 *  solution_text;
 *  solution_path;      //
 *  remote:             // github
 *  revision;           // lineage-20.0
 */

struct Columns {
    int     row;
    QString name;
    QString path;
    QString realpath;       //
    bool    checkeouted;    // true: 已检出
    QString checkeouted_text;
    bool    solution;       // true: 正常
    QString solution_text;
    QString solution_path;  //
    QString remote;
    QString revision;
};

//
class ColumnsList : public QList<Columns> {
public:
    QStringList realpaths() {
        QList<QString> result;
        result.reserve(this->size());

        for (const auto& column : *this) {
            result.append(column.realpath);
        }

        return result;
    }
};

template<typename T, typename F>
auto map(const QList<T> &list, F func) -> QList<decltype(func(std::declval<T>()))> {
    using ResultType = decltype(func(std::declval<T>()));
    QList<ResultType> result;

    result.reserve(list.size());

    for (const auto& item : list) {
        result.append(func(item));
    }

    return result;
}

class ColumnsEntry
{
public:
    ColumnsEntry();
};

#endif // COLUMNSENTRY_H
